﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using ARSys.Entity;
using Wicresoft.Task.ARNotice.Emails;

namespace Wicresoft.Task.ARNotice
{
    static class EmailFactory
    {
        public static dynamic Bag { get; set; }

        public static EmailTemplate CreateEmailTemplate(Email armail, ARSysContext dc)
        {
            var other = new
            {
                WebsiteLink = Bag.BaseUrl,
                MyVMUrl = Bag.MyVMUrl,
                MyActivityUrl = Bag.MyActivityUrl,
            };

            switch (armail.RequestType)
            {
                // 过期提醒
                case "Expire Notify":
                    {
                        return new ExpireNotify(armail, dc, armail, other);
                    }
                // 关机提醒
                case "Shutdown Notify":
                    {
                        return new ShutdownNotify(armail, dc, armail, other);
                    }
                // 释放提醒
                case "Release Notify":
                    {
                        return new ReleaseNotify(armail, dc, armail, other);
                    }
                // 停止备份提醒
                case "StopBackup Notify":
                    {
                        return new StopBackupNotify(armail, dc, armail, other);
                    }
                // 流程提醒
                default:
                    if (string.IsNullOrEmpty(armail.AskForMoreGuy))
                    {
                        switch (armail.RequestStatus)
                        {
                            case "Rejected":
                                return new Rejected(armail, dc, armail, other);
                            default:
                                return new PendingForApproval(armail, dc, armail, other);
                        }
                    }
                    else
                        return new AskForMore(armail, dc, armail, other);
            }
        }
    }
}
